#!/bin/bash
MASTER_USER=${MYSQL_MASTER_USER:-repl}
MASTER_PASSWORD=${MYSQL_MASTER_PASSWORD:-repl@3721}
ROOT_USER=${MYSQL_ROOT_USER:-root}
ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-qingcloudEC@3721}
ALLOW_HOST=${ALLOW_HOST:-%}

mysql -u$ROOT_USER -p$ROOT_PASSWORD -e "CREATE USER '$MASTER_USER'@'$ALLOW_HOST' IDENTIFIED BY '$MASTER_PASSWORD';"
mysql -u$ROOT_USER -p$ROOT_PASSWORD -e "GRANT REPLICATION SLAVE,REPLICATION CLIENT ON *.* TO '$MASTER_USER'@'$ALLOW_HOST';"
mysql -u$ROOT_USER -p$ROOT_PASSWORD -e "FLUSH PRIVILEGES;"
